<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - include/yaml-cpp/node/detail/node_iterator.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">include/yaml-cpp/node/detail</a> - node_iterator.h<span style="font-size: 80%;"> (source / <a href="node_iterator.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">36</td>
            <td class="headerCovTableEntry">46</td>
            <td class="headerCovTableEntryMed">78.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">14</td>
            <td class="headerCovTableEntry">29</td>
            <td class="headerCovTableEntryLo">48.3 %</td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66</a>
<span class="lineNum">       2 </span>            : #define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : #if defined(_MSC_VER) ||                                            \
<span class="lineNum">       5 </span>            :     (defined(__GNUC__) &amp;&amp; (__GNUC__ == 3 &amp;&amp; __GNUC_MINOR__ &gt;= 4) || \
<span class="lineNum">       6 </span>            :      (__GNUC__ &gt;= 4))  // GCC supports &quot;pragma once&quot; correctly since 3.4
<span class="lineNum">       7 </span>            : #pragma once
<span class="lineNum">       8 </span>            : #endif
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;yaml-cpp/dll.h&quot;
<span class="lineNum">      11 </span>            : #include &quot;yaml-cpp/node/ptr.h&quot;
<span class="lineNum">      12 </span>            : #include &lt;cstddef&gt;
<span class="lineNum">      13 </span>            : #include &lt;iterator&gt;
<span class="lineNum">      14 </span>            : #include &lt;memory&gt;
<span class="lineNum">      15 </span>            : #include &lt;map&gt;
<span class="lineNum">      16 </span>            : #include &lt;utility&gt;
<span class="lineNum">      17 </span>            : #include &lt;vector&gt;
<span class="lineNum">      18 </span>            : 
<span class="lineNum">      19 </span>            : namespace YAML {
<span class="lineNum">      20 </span>            : namespace detail {
<span class="lineNum">      21 </span>            : struct iterator_type {
<span class="lineNum">      22 </span>            :   enum value { None, Sequence, Map };
<span class="lineNum">      23 </span>            : };
<span class="lineNum">      24 </span>            : 
<span class="lineNum">      25 </span>            : template &lt;typename V&gt;
<span class="lineNum">      26 </span>            : struct node_iterator_value : public std::pair&lt;V*, V*&gt; {
<a name="27"><span class="lineNum">      27 </span>            :   typedef std::pair&lt;V*, V*&gt; kv;</a>
<a name="28"><span class="lineNum">      28 </span>            : </a>
<a name="29"><span class="lineNum">      29 </span><span class="lineNoCov">          0 :   node_iterator_value() : kv(), pNode(0) {}</span></a>
<span class="lineNum">      30 </span><span class="lineCov">      34698 :   explicit node_iterator_value(V&amp; rhs) : kv(), pNode(&amp;rhs) {}</span>
<a name="31"><span class="lineNum">      31 </span><span class="lineCov">      73024 :   explicit node_iterator_value(V&amp; key, V&amp; value) : kv(&amp;key, &amp;value), pNode(0) {}</span></a>
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span><span class="lineCov">      34698 :   V&amp; operator*() const { return *pNode; }</span>
<span class="lineNum">      34 </span>            :   V&amp; operator-&gt;() const { return *pNode; }
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            :   V* pNode;
<span class="lineNum">      37 </span>            : };
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : typedef std::vector&lt;node*&gt; node_seq;
<span class="lineNum">      40 </span>            : typedef std::map&lt;node*, node*&gt; node_map;
<span class="lineNum">      41 </span>            : 
<span class="lineNum">      42 </span>            : template &lt;typename V&gt;
<span class="lineNum">      43 </span>            : struct node_iterator_type {
<span class="lineNum">      44 </span>            :   typedef node_seq::iterator seq;
<span class="lineNum">      45 </span>            :   typedef node_map::iterator map;
<span class="lineNum">      46 </span>            : };
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            : template &lt;typename V&gt;
<span class="lineNum">      49 </span>            : struct node_iterator_type&lt;const V&gt; {
<span class="lineNum">      50 </span>            :   typedef node_seq::const_iterator seq;
<span class="lineNum">      51 </span>            :   typedef node_map::const_iterator map;
<span class="lineNum">      52 </span>            : };
<span class="lineNum">      53 </span>            : 
<span class="lineNum">      54 </span>            : template &lt;typename V&gt;
<span class="lineNum">      55 </span>            : class node_iterator_base
<span class="lineNum">      56 </span>            :     : public std::iterator&lt;std::forward_iterator_tag, node_iterator_value&lt;V&gt;,
<span class="lineNum">      57 </span>            :                            std::ptrdiff_t, node_iterator_value&lt;V&gt;*,
<span class="lineNum">      58 </span>            :                            node_iterator_value&lt;V&gt; &gt; {
<span class="lineNum">      59 </span>            :  private:
<span class="lineNum">      60 </span>            :   struct enabler {};
<a name="61"><span class="lineNum">      61 </span>            : </a>
<a name="62"><span class="lineNum">      62 </span>            :   struct proxy {</a>
<span class="lineNum">      63 </span><span class="lineCov">      73024 :     explicit proxy(const node_iterator_value&lt;V&gt;&amp; x) : m_ref(x) {}</span>
<span class="lineNum">      64 </span><span class="lineCov">      73024 :     node_iterator_value&lt;V&gt;* operator-&gt;() { return std::addressof(m_ref); }</span>
<span class="lineNum">      65 </span>            :     operator node_iterator_value&lt;V&gt;*() { return std::addressof(m_ref); }
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            :     node_iterator_value&lt;V&gt; m_ref;
<span class="lineNum">      68 </span>            :   };
<span class="lineNum">      69 </span>            : 
<span class="lineNum">      70 </span>            :  public:
<span class="lineNum">      71 </span>            :   typedef typename node_iterator_type&lt;V&gt;::seq SeqIter;
<span class="lineNum">      72 </span>            :   typedef typename node_iterator_type&lt;V&gt;::map MapIter;
<a name="73"><span class="lineNum">      73 </span>            :   typedef node_iterator_value&lt;V&gt; value_type;</a>
<span class="lineNum">      74 </span>            : 
<a name="75"><span class="lineNum">      75 </span><span class="lineNoCov">          0 :   node_iterator_base()</span></a>
<span class="lineNum">      76 </span><span class="lineNoCov">          0 :       : m_type(iterator_type::None), m_seqIt(), m_mapIt(), m_mapEnd() {}</span>
<span class="lineNum">      77 </span><span class="lineCov">      60054 :   explicit node_iterator_base(SeqIter seqIt)</span>
<span class="lineNum">      78 </span>            :       : m_type(iterator_type::Sequence),
<span class="lineNum">      79 </span>            :         m_seqIt(seqIt),
<a name="80"><span class="lineNum">      80 </span>            :         m_mapIt(),</a>
<span class="lineNum">      81 </span><span class="lineCov">      60054 :         m_mapEnd() {}</span>
<span class="lineNum">      82 </span><span class="lineCov">      81240 :   explicit node_iterator_base(MapIter mapIt, MapIter mapEnd)</span>
<span class="lineNum">      83 </span>            :       : m_type(iterator_type::Map),
<span class="lineNum">      84 </span>            :         m_seqIt(),
<span class="lineNum">      85 </span>            :         m_mapIt(mapIt),
<span class="lineNum">      86 </span><span class="lineCov">      81240 :         m_mapEnd(mapEnd) {</span>
<span class="lineNum">      87 </span><span class="lineCov">      81240 :     m_mapIt = increment_until_defined(m_mapIt);</span>
<span class="lineNum">      88 </span><span class="lineCov">      81240 :   }</span>
<span class="lineNum">      89 </span>            : 
<span class="lineNum">      90 </span>            :   template &lt;typename W&gt;
<span class="lineNum">      91 </span>            :   node_iterator_base(const node_iterator_base&lt;W&gt;&amp; rhs,
<span class="lineNum">      92 </span>            :                      typename std::enable_if&lt;std::is_convertible&lt;W*, V*&gt;::value,
<span class="lineNum">      93 </span>            :                                              enabler&gt;::type = enabler())
<span class="lineNum">      94 </span>            :       : m_type(rhs.m_type),
<span class="lineNum">      95 </span>            :         m_seqIt(rhs.m_seqIt),
<span class="lineNum">      96 </span>            :         m_mapIt(rhs.m_mapIt),
<span class="lineNum">      97 </span>            :         m_mapEnd(rhs.m_mapEnd) {}
<span class="lineNum">      98 </span>            : 
<span class="lineNum">      99 </span>            :   template &lt;typename&gt;
<span class="lineNum">     100 </span>            :   friend class node_iterator_base;
<a name="101"><span class="lineNum">     101 </span>            : </a>
<span class="lineNum">     102 </span>            :   template &lt;typename W&gt;
<span class="lineNum">     103 </span><span class="lineCov">     106252 :   bool operator==(const node_iterator_base&lt;W&gt;&amp; rhs) const {</span>
<span class="lineNum">     104 </span><span class="lineCov">     106252 :     if (m_type != rhs.m_type)</span>
<span class="lineNum">     105 </span><span class="lineNoCov">          0 :       return false;</span>
<span class="lineNum">     106 </span>            : 
<span class="lineNum">     107 </span><span class="lineCov">     106252 :     switch (m_type) {</span>
<span class="lineNum">     108 </span>            :       case iterator_type::None:
<span class="lineNum">     109 </span><span class="lineNoCov">          0 :         return true;</span>
<span class="lineNum">     110 </span>            :       case iterator_type::Sequence:
<span class="lineNum">     111 </span><span class="lineCov">      47376 :         return m_seqIt == rhs.m_seqIt;</span>
<span class="lineNum">     112 </span>            :       case iterator_type::Map:
<span class="lineNum">     113 </span><span class="lineCov">      58876 :         return m_mapIt == rhs.m_mapIt;</span>
<span class="lineNum">     114 </span>            :     }
<span class="lineNum">     115 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">     116 </span>            :   }
<a name="117"><span class="lineNum">     117 </span>            : </a>
<span class="lineNum">     118 </span>            :   template &lt;typename W&gt;
<span class="lineNum">     119 </span><span class="lineCov">     106252 :   bool operator!=(const node_iterator_base&lt;W&gt;&amp; rhs) const {</span>
<span class="lineNum">     120 </span><span class="lineCov">     106252 :     return !(*this == rhs);</span>
<a name="121"><span class="lineNum">     121 </span>            :   }</a>
<span class="lineNum">     122 </span>            : 
<span class="lineNum">     123 </span><span class="lineCov">      71210 :   node_iterator_base&lt;V&gt;&amp; operator++() {</span>
<span class="lineNum">     124 </span><span class="lineCov">      71210 :     switch (m_type) {</span>
<span class="lineNum">     125 </span>            :       case iterator_type::None:
<span class="lineNum">     126 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     127 </span>            :       case iterator_type::Sequence:
<span class="lineNum">     128 </span><span class="lineCov">      34698 :         ++m_seqIt;</span>
<span class="lineNum">     129 </span><span class="lineCov">      34698 :         break;</span>
<span class="lineNum">     130 </span>            :       case iterator_type::Map:
<span class="lineNum">     131 </span><span class="lineCov">      36512 :         ++m_mapIt;</span>
<span class="lineNum">     132 </span><span class="lineCov">      36512 :         m_mapIt = increment_until_defined(m_mapIt);</span>
<span class="lineNum">     133 </span><span class="lineCov">      36512 :         break;</span>
<span class="lineNum">     134 </span>            :     }
<span class="lineNum">     135 </span><span class="lineCov">      71210 :     return *this;</span>
<span class="lineNum">     136 </span>            :   }
<span class="lineNum">     137 </span>            : 
<span class="lineNum">     138 </span>            :   node_iterator_base&lt;V&gt; operator++(int) {
<span class="lineNum">     139 </span>            :     node_iterator_base&lt;V&gt; iterator_pre(*this);
<span class="lineNum">     140 </span>            :     ++(*this);
<span class="lineNum">     141 </span>            :     return iterator_pre;
<a name="142"><span class="lineNum">     142 </span>            :   }</a>
<span class="lineNum">     143 </span>            : 
<span class="lineNum">     144 </span><span class="lineCov">     107722 :   value_type operator*() const {</span>
<span class="lineNum">     145 </span><span class="lineCov">     107722 :     switch (m_type) {</span>
<span class="lineNum">     146 </span>            :       case iterator_type::None:
<span class="lineNum">     147 </span><span class="lineNoCov">          0 :         return value_type();</span>
<span class="lineNum">     148 </span>            :       case iterator_type::Sequence:
<span class="lineNum">     149 </span><span class="lineCov">      34698 :         return value_type(**m_seqIt);</span>
<span class="lineNum">     150 </span>            :       case iterator_type::Map:
<span class="lineNum">     151 </span><span class="lineCov">      73024 :         return value_type(*m_mapIt-&gt;first, *m_mapIt-&gt;second);</span>
<span class="lineNum">     152 </span>            :     }
<span class="lineNum">     153 </span><span class="lineNoCov">          0 :     return value_type();</span>
<a name="154"><span class="lineNum">     154 </span>            :   }</a>
<span class="lineNum">     155 </span>            : 
<a name="156"><span class="lineNum">     156 </span><span class="lineCov">      73024 :   proxy operator-&gt;() const { return proxy(**this); }</span></a>
<span class="lineNum">     157 </span>            : 
<span class="lineNum">     158 </span><span class="lineCov">     117752 :   MapIter increment_until_defined(MapIter it) {</span>
<span class="lineNum">     159 </span><span class="lineCov">     117752 :     while (it != m_mapEnd &amp;&amp; !is_defined(it))</span>
<span class="lineNum">     160 </span><span class="lineNoCov">          0 :       ++it;</span>
<span class="lineNum">     161 </span><span class="lineCov">     117752 :     return it;</span>
<a name="162"><span class="lineNum">     162 </span>            :   }</a>
<span class="lineNum">     163 </span>            : 
<span class="lineNum">     164 </span><span class="lineCov">      36512 :   bool is_defined(MapIter it) const {</span>
<span class="lineNum">     165 </span><span class="lineCov">      36512 :     return it-&gt;first-&gt;is_defined() &amp;&amp; it-&gt;second-&gt;is_defined();</span>
<span class="lineNum">     166 </span>            :   }
<span class="lineNum">     167 </span>            : 
<span class="lineNum">     168 </span>            :  private:
<span class="lineNum">     169 </span>            :   typename iterator_type::value m_type;
<span class="lineNum">     170 </span>            : 
<span class="lineNum">     171 </span>            :   SeqIter m_seqIt;
<span class="lineNum">     172 </span>            :   MapIter m_mapIt, m_mapEnd;
<span class="lineNum">     173 </span>            : };
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span>            : typedef node_iterator_base&lt;node&gt; node_iterator;
<span class="lineNum">     176 </span>            : typedef node_iterator_base&lt;const node&gt; const_node_iterator;
<span class="lineNum">     177 </span>            : }
<span class="lineNum">     178 </span>            : }
<span class="lineNum">     179 </span>            : 
<span class="lineNum">     180 </span>            : #endif  // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
